package app.models.member;

import com.github.sog.annotation.TableBind;
import com.github.sog.plugin.sqlinxml.SqlKit;
import com.jfinal.plugin.activerecord.Model;

import java.util.Date;

/**
 * <p>
 * .
 * </p>
 *
 * @author Jerry Ou
 * @version 1.0 2014-05-04 20:05
 * @since JDK 1.6
 */
@TableBind(tableName = "ol_phone_collection")
public class PhoneCollection extends Model<PhoneCollection> {
    private static final long   serialVersionUID = 1L;

    public static final  PhoneCollection dao = new PhoneCollection();

    public void collection(String phone, String wxno) {
        if (findByPhone(phone) == null) {
            PhoneCollection c = new PhoneCollection();
            c.set("phone", phone);
            c.set("wx_no", wxno);
            c.set("create_time", new Date());
            c.save();
        }
    }

    public PhoneCollection findByPhone(String phone) {
        return findFirst(SqlKit.sql("phonecollection.findByPhone"), phone);
    }

}
